<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <form method="POST" id="list" action="{:U('proExport')}">

    <div class="main-title">
        <h2>{$title}</h2>
        <button type="submit" class="btn confirm btn-default">批量导出</button>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn btn-primary" href="{:U('Material/addproduct')}">新 增</a>
        </div>

    </div>
    <div class="search-form fr cf">
        <div class="sleft">
            <select  class="search-input select2 search-input" name="classify" style="height: 30px;width:120px">
                <option value="">所有货别</option>
                <volist name="_classify" id="c">
                    <option value="{$c.classify_no}" {:I('classify')==$c['classify_no']?"selected":""}> {$c.classify}</option>
                </volist>
            </select>
        </div>
        <div class="sleft">
            <select name="status" class="search-input " style="height: 30px;width:120px">
                <option value="">所有状态类型</option>
                <option value="1" {$status==1?"selected":""}>正常</option>
                <option value="0" {$status==0?"selected":""}>禁用</option>
            </select>
        </div>
        <div class="sleft">
            <input type="text" name="pname" class="search-input " value="{:I('pname')}" placeholder="请输入商品名称" style="height: 30px;width:120px">

        </div>
        <div class="sleft">
            <input type="text" name="BIN" class="search-input" value="{:I('BIN')}" placeholder="请输入编码" style="height: 30px;width:120px">
            <a class="sch-btn" href="javascript:;" id="search" url="{:U('productmanage')}"><i class="btn-search"></i></a>
        </div>
    </div>
    </form>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
	<table>
        <thead>
        <tr>
            <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
            <th>编号</th>
            <th>货别</th>
            <th>水果分类</th>
            <th>商品名</th>
            <th>规格</th>
            <th>状态</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <notempty name="_list">
            <volist name="_list" id="vo">
                <tr>
                    <td><input  type="checkbox" class="ids" name="id[]" value="{$vo.id}" /></td>
                    <td>
                        <a href="{:U('inventory/inventoryrealtime')}&BIN={$vo.BIN}">{$vo.BIN}</a>
                    </td>
                    <td>{$vo.classify}</td>
                    <td>{$vo.fruit_classify}</td>
                    <td>{$vo.pname}</td>
                    <td>{$vo.spec}</td>
                    <td>{$vo.status|get_material_status}</td>
                    <td>
                        <a href="{:U('Material/editproduct',array('BIN'=>$vo['BIN']))}" class="btn btn-primary">修改</a>
                        <a href="{:U('Material/productdel',array('BIN'=>$vo['BIN']))}" class="btn btn-danger ajax-get confirm">删除</a>
                        <if condition="$vo['status'] eq 1">
                            <a href="{:U('Material/productforbid',array('BIN'=>$vo['BIN']))}" class="btn btn-warning ajax-get confirm">禁用</a>
                        </if>
                        <if condition="$vo['status'] eq 0">
                            <a href="{:U('Material/productresume',array('BIN'=>$vo['BIN']))}" class="btn btn-success ajax-get confirm">启用</a>
                        </if>
                    </td>
                </tr>
            </volist>
            <else/>
            <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
        </notempty>
        </tbody>
    </table>
	</div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script type="text/javascript">
        //搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('.search-input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});
	//回车搜索
	$(".search-input").keyup(function(e){
		if(e.keyCode === 13){
			$("#search").click();
			return false;
		}
	});
        
        //导航高亮
        highlight_subnav('{:U('Material/productmanage')}');
    </script>
</block>
